﻿using DataModels.Entities.ShoppingMall;
using DataModels.Enums.ShoppingMall;
using Utils;
using static DataModels.Enums.GeneralEnum;

namespace DataModels.Dto.ShoppingMallDto
{
    public class GetProductInfo : PageRequest
    {
        /// <summary>
        /// 分类ID
        /// </summary>
        public Guid? CategoryUUID { get; set; }

        /// <summary>
        /// 小分类ID
        /// </summary>
        public Guid? SubCategoryUUID { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status? IsRecommend { get; set; }

        /// <summary>
        /// 搜索
        /// </summary>
        public string? SearchWord { get; set; }

        /// <summary>
        /// 店铺ID
        /// </summary>
        public Guid? StoreUUID { get; set; }

    }

    public class GetProductDto
    {
        public Guid UUID { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 商品图片
        /// </summary>
        public string ImageUrl { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status IsRecommend { get; set; }

        /// <summary>
        /// 服务名称
        /// </summary>
        public List<string> Services { get; set; }

        /// <summary>
        /// 价格
        /// </summary>
        public Decimal Price { get; set; }

        /// <summary>
        /// 原始价格 - 非购买价格
        /// </summary>
        public decimal OriginalPrice { get; set; }

        /// <summary>
        /// 销售数量 - 订单完成数量
        /// </summary>
        public int OrderCount { get; set; } = 0;

        /// <summary>
        /// 是否拼团商品
        /// </summary>
        public Status IsGroup { get; set; }

    }

    public class GetProductDetailDto
    {
        public Guid UUID { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Title { get; set; }

        /// <summary>
        /// 成交数量
        /// </summary>
        public int DealtQuantity { get; set; }

        /// <summary>
        /// 副标题
        /// </summary>
        public string Subtitle { get; set; }

        /// <summary>
        /// 商品描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 是否推荐
        /// </summary>
        public Status IsRecommend { get; set; }

        /// <summary>
        /// 主图URL
        /// </summary>
        public string ImageUrl { get; set; }

        /// <summary>
        /// 商品图片
        /// </summary>
        public List<string> ImageUrls { get; set; }

        /// <summary>
        /// 标签
        /// </summary>
        public List<ProductTagDto> Tags { get; set; }

        /// <summary>
        /// 是否拼团商品
        /// </summary>
        public Status IsGroup { get; set; }

        /// <summary>
        /// 拼团结束时间
        /// </summary>
        public DateTime? GroupEndTime { get; set; }

        /// <summary>
        /// 成团人数
        /// </summary>
        public int GroupCount { get; set; }

        /// <summary>
        /// 最大成团人数
        /// </summary>
        public int MaxGroupCount { get; set; }

        /// <summary>
        /// 规格
        /// </summary>
        public List<SpecificationDto> Specifications { get; set; }

        /// <summary>
        /// 店铺ID
        /// </summary>
        public Guid StoreUUID { get; set; }

        /// <summary>
        /// 店铺名称
        /// </summary>
        public string StoreName { get; set; }

        /// <summary>
        /// 订单量
        /// </summary>
        public int OrderCount { get; set; }

        /// <summary>
        /// 订单数量
        /// </summary>
        public List<ProductServices> Services { get; set; }

        public int CommentCount { get; set; } = 0;

        public  int AverageRating { get; set; } = 5; // 平均评分，默认5星   
    }
    public class SpecificationDto
    {

        public Guid SpecificationUUID { get; set; }

        /// <summary>
        /// 商品价格
        /// </summary>
        public decimal Price { get; set; }

        /// <summary>
        /// 商品拼团价格
        /// </summary>
        public decimal GroupPrice { get; set; }

        /// <summary>
        /// 原始价格 - 非购买价格
        /// </summary>
        public decimal OriginalPrice { get; set; }

        /// <summary>
        /// 商品规格名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 剩余数量
        /// </summary>
        public int Count { get; set; }
    }

    public class ProductTagDto
    {
        /// <summary>
        /// 标签名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 介绍
        /// </summary>
        public string Description { get; set; }
    }
    public class ProductServices
    {
        public Guid UUID { get; set; }
        /// <summary>
        /// 服务名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 服务介绍
        /// </summary>
        public string Description { get; set; }
    }

    public class ShoppingMallSubmitOrderInfo
    {
        /// <summary>
        /// 商品UUID
        /// </summary>
        [GeneralRequired]
        public Guid ProductUUID { get; set; }

        /// <summary>
        /// 规格UUID
        /// </summary>
        [GeneralRequired]
        public Guid SpecificationUUID { get; set; }

        /// <summary>
        /// 是否参团购买
        /// </summary>
        public Status JoinGroup { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        [GeneralRequired]
        public int Count { get; set; }

        /// <summary>
        /// 地址
        /// </summary>
        [GeneralRequired]
        public Guid AddressUUID { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 备注的图片
        /// </summary>
        public List<string>? ImageUrls { get; set; } = [];
    }

    public class ShoppingMallOrderPaymentInfo
    {
        [GeneralRequired]
        public Guid OrderUUID { get; set; }
    }

    public class GetOrderInfo : PageRequest
    {
        public ShoppingMallOrderStatus? OrderStatus { get; set; }

        public Guid? OrderTotalUUID { get; set; }
        public Guid? OrderUUID { get; set; }

    }

    public class GetProductOrdersInfo : PageRequest
    {
        [GeneralRequired]
        public Guid ProductUUID { get; set; }

        public Status? IsGroup { get; set; }
    }

    public class GetOrderInfoDto
    {
        public Guid OrderTotalUUID { get; set; }
        public string OrderNo { get; set; }

        /// <summary>
        /// 订单金额
        /// </summary>
        public decimal OrderAmount { get; set; }

        /// <summary>
        /// 支付金额
        /// </summary>
        public decimal PayAmount { get; set; }

        /// <summary>
        /// 优惠金额
        /// </summary>
        public decimal DiscountAmount { get; set; } = 0;

        /// <summary>
        /// 收货地址
        /// </summary>
        public string Address { get; set; }

        /// <summary>
        /// 联系人姓名
        /// </summary>
        public string ContactPerson { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string ContactPhone { get; set; }

        public List<ShoppingMallOrder> OrderDetail { get;set;}
    }

    public class ShoppingMallSubmitOrderComment
    {
        /// <summary>
        /// 订单UUID
        /// </summary>
        [GeneralRequired]
        public Guid OrderUUID { get; set; }

        public ShoppingMallOrderStarRating StarRating { get; set; } = ShoppingMallOrderStarRating.FiveStars;

        [GeneralRequired]
        public string Text { get; set; }

        public List<string>? Urls { get; set; } = [];
    }

    public class GetOrderCommentInfo: PageRequest
    {
        [GeneralRequired]
        public Guid ProductUUID { get; set; }
        public Guid? OrderUUID { get; set; }

        public Guid? UserUUID { get; set; }


        /// <summary>
        /// 筛选星级评分
        /// </summary>
        public List<ShoppingMallOrderStarRating> sr { get; set; } = [ShoppingMallOrderStarRating.FiveStars, ShoppingMallOrderStarRating.FourStars, ShoppingMallOrderStarRating.ThreeStars, ShoppingMallOrderStarRating.TwoStars, ShoppingMallOrderStarRating.OneStar];

        /// <summary>
        /// 筛选有图的
        /// </summary>
        public Status FilterImages { get; set; } = Status.Disable;
    }

    public class GetOrderCommentDto
    {
        public Guid UUID { get; set; }
        public ShoppingMallOrderStarRating StarRating { get; set; } = ShoppingMallOrderStarRating.FiveStars;
        public string UserName { get; set; }

        public string Content { get; set; }

        public DateTime CreateTime { get; set; }
        public Guid CreateUserUUID { get; set; }
        public string? AvatarUrl { get; set; }
        public List<string> Urls { get; set; }
    }
}